//
//  UIView+YYSGetViewController.m
//  CarCar
//
//  Created by gonglei on 17/3/8.
//  Copyright © 2017年 yys. All rights reserved.
//

#import "UIView+YYSGetViewController.h"

@implementation UIView (YYSGetViewController)

/**
 *  拿到当前控制器的方法
 */
- (UIViewController *)viewController {
    UIResponder *next = self.nextResponder;
    do {
        //判断响应者是否为视图控制器
        if ([next isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)next;
        }
        next = next.nextResponder;
    } while (next != nil);
    
    return nil;
}

@end
